home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.2 Applications 1996 May
/
SGI IRIX 6.2 Applications 1996 May.iso
/
dist
/
impr_dev.idb
/
usr
/
impressario
/
src
/
libspool
/
SLErrors.c.z
/
SLErrors.c
Wrap
C/C++ Source or Header
|
1996-05-06
|
6KB
|
178 lines
/**************************************************************************
* *
* Copyright (c) 1991 Silicon Graphics, Inc. *
* All Rights Reserved *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
* *
* The copyright notice above does not evidence any actual of intended *
* publication of such source code, and is an unpublished work by Silicon *
* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
* the property of Silicon Graphics, Inc. Any use, duplication or *
* disclosure not specifically authorized by Silicon Graphics is strictly *
* prohibited. *
* *
* RESTRICTED RIGHTS LEGEND: *
* *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
* Technical Data and Computer Software clause at DFARS 52.227-7013, *
* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
* Supplement. Unpublished - rights reserved under the Copyright Laws of *
* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
* Shoreline Blvd., Mountain View, CA 94039-7311 *
**************************************************************************
*
* File: SLErrors.c
*
* Description: Contains error messages and error handling code for the
* libspool library.
*
**************************************************************************/
#ident "$Revision: 1.4 $"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "spoolI.h"
/* Global Error Variable */
int SLerrno = SL_NOERROR;
/* Error List - error codes are indices into this list */
char *SLerrlist[] = {
/* 0 */ "no error detected",
/* 1 */ "error while finding spoolers",
/* 2 */ "SL_SPOOLER_NONE specified as default",
/* 3 */ "no spooling systems available",
/* 4 */ "spooling system specified is not available",
/* 5 */ "Invalid or missing filename specified",
/* 6 */ "invalid number of copies to print specified",
/* 7 */ "invalid job copy/link parameter specified",
/* 8 */ "no default printer registered with spooler",
/* 9 */ "spooling system error",
/* 10 */ "no job ID specified for cancellation",
/* 11 */ "invalid spooling function specified",
/* 12 */ "invalid spooling function state specified",
/* 13 */ "could not get spooler function state",
/* 14 */ "invalid printer structure specified",
/* 15 */ "error during remote execution (rsh)",
/* 16 */ "root privilege required for this function",
/* 17 */ "invalid mail parameter specified",
/* 18 */ "invalid file descriptor specified",
/* 19 */ "invalid buffer or amount specified",
/* 20 */ "invalid printer name specified",
/* 21 */ "invalid printer in class",
/* 22 */ "unable to create temporary file",
/* 23 */ "socket error",
/* 24 */ "printer does not support fast job submittal",
/* 25 */ "function requires System V spooler be selected",
/* 26 */ "cannot save options file",
};
int SLnerr = sizeof(SLerrlist)/sizeof(char*);
/* Message catalog lookup table. The error code selects the corresponding
message number.
*/
static char *SLmsgnum[] = {
/* 0 */ _SGI_LIBSPOOL_NOERROR,
/* 1 */ _SGI_LIBSPOOL_ERR_FIND_SPOOLER,
/* 2 */ _SGI_LIBSPOOL_ERR_SPOOLER_NONE,
/* 3 */ _SGI_LIBSPOOL_ERR_NO_SPOOLERS,
/* 4 */ _SGI_LIBSPOOL_ERR_SPOOLER_UNKNOWN,
/* 5 */ _SGI_LIBSPOOL_ERR_NO_FILENAME,
/* 6 */ _SGI_LIBSPOOL_ERR_NUM_COPIES,
/* 7 */ _SGI_LIBSPOOL_ERR_JOB_COPY,
/* 8 */ _SGI_LIBSPOOL_ERR_NO_DEF_PRINTER,
/* 9 */ _SGI_LIBSPOOL_ERR_SPOOLER_ERROR,
/* 10 */ _SGI_LIBSPOOL_ERR_NO_JOBID,
/* 11 */ _SGI_LIBSPOOL_ERR_BAD_FUNCTION,
/* 12 */ _SGI_LIBSPOOL_ERR_BAD_STATE,
/* 13 */ _SGI_LIBSPOOL_ERR_NO_STATE,
/* 14 */ _SGI_LIBSPOOL_ERR_BAD_PRINTER_STRUCT,
/* 15 */ _SGI_LIBSPOOL_ERR_REMOTE,
/* 16 */ _SGI_LIBSPOOL_ERR_PRIVILEGE,
/* 17 */ _SGI_LIBSPOOL_ERR_MAIL,
/* 18 */ _SGI_LIBSPOOL_ERR_BAD_FD,
/* 19 */ _SGI_LIBSPOOL_ERR_BAD_BUF,
/* 20 */ _SGI_LIBSPOOL_ERR_BAD_PRINTER_NAME,
/* 21 */ _SGI_LIBSPOOL_ERR_BAD_CLASS_MEMBER,
/* 22 */ _SGI_LIBSPOOL_ERR_NO_TEMP_FILE,
/* 23 */ _SGI_LIBSPOOL_ERR_BAD_SOCKET,
/* 24 */ _SGI_LIBSPOOL_ERR_NO_FAST_JOB,
/* 25 */ _SGI_LIBSPOOL_ERR_NO_SYSV,
/* 26 */ _SGI_LIBSPOOL_ERR_SAVE_OPTIONS,
};
/**************************************************************************
*
* Function: SLPerror
*
* Description: Similar to the C function perror, this function produces
* a message on the standard error output, describing the last error
* encountered during an SL function call. The arguement s is printed
* first, then a colon and a blank, then the error message and a
* new-line. If s="" then the colon and blank are not printed.
*
* The function uses the global variable SLerrno as an index into a
* global list of error strings, SLErrlist. The values for SLerrno
* are contained in spool.h. The global SLnerr contains the number of
* error strings in SLerrlist.
*
* Parameters:
* s (I) - User supplied error string to prepend on SL error string
*
* Return: none
*
**************************************************************************/
void SLPerror(const char *s)
{
if (s && strlen(s)) /* Check for NULL string */
(void)fprintf(stderr, "%s: ",s); /* User string + ':' */
(void)fprintf(stderr, "%s\n", SLErrorString(SLerrno));
}
/**************************************************************************
*
* Function: SLErrorString
*
* Description: Returns the error string corresponding to the specified
* error code. If the code is not in the range of valid SL error
* codes a string with the error code number is returned.
*
* Parameters:
* err (I) - SL error code
*
* Return: String corresponding to the specified error code.
*
**************************************************************************/
char *SLErrorString(int err)
{
static char buf[128];
/*
* If this is a valid SL error code return the
* standard error string.
*/
if (err >= 0 && err < SLnerr)
return (gettxt(SLmsgnum[err], SLerrlist[err]));
/*
* If the code is invalid return a string with the error code
*/
(void)sprintf(buf, gettxt(_SGI_LIBSPOOL_UNKNOWN_ERROR,
"error code %d"), err);
return buf;
}